

public class Book {

  // Fields
  private String title;
  private int numOfPages;
  private double price;
  private int quantity;

  // Constructor
  public Book(String thetitle, int pages, double cost, int num) {
    title = thetitle;
    numOfPages = pages;
    price = cost;
    quantity = num;
  }


  // getTitle
  public String getTitle() {
          return title;
  }

  // getPrice
  public double getPrice() {
      return price;
  }

        // getQuantity
        public int getQuantity() {
                return quantity;
        }

  // toString
  public String toString() {
    return ("Title           : " + title + "\n" +
            "Number of Pages : " + numOfPages + "\n" +
            "Price           : " + price + "\n" +
            "Quantity        : " + quantity + "\n" );
  }

        // subtractQuantity
  public void subtractQuantity(int change) {
    quantity = quantity - change;
  }


  // addQuantity
  public void addQuantity(int change) {
    if (change>0)
      quantity = quantity + change;
  }


} // END OF BOOK CLASS






